<div class="paddingT15 paddingB15" id="cartWrapper">
<table class="table">
	<thead>
    	<tr>
            <th><?php echo __("Product"); ?></th>
            <th style="text-align:center;"><?php echo __("Qty"); ?></th>
            <th><?php echo __("Price"); ?></th>
            <th style="text-align:center;"><?php echo __("Del"); ?></th>
        </tr>
    </thead>
    <?php $totalPrice = 0; ?>
	<?php foreach ($cart_list as $key=>$cart_item) : ?>
    	<?php 
			$price = (int)$cart_item['product']->discount_price * $cart_item['quantity'];
			$totalPrice += $price;
		?>
    <tr>
        <td ><?php echo $cart_item['product']->name; ?> <?php echo ($cart_item['option'])?("- ".$cart_item['option']->name):""; ?></td>
        <td style="text-align:center;"><?php echo $cart_item['quantity']; ?></td>
        <td><?php echo format_number($price) ?> $</td>
        <td style="text-align:center;"><a href="#" class="icon16 typ-icon-delete red btnCartDel" prod="<?php echo $cart_item['product_id']; ?>" opt="<?php echo $cart_item['option_id']; ?>"></a></td>
    </tr>
    <?php endforeach; ?>
    <tr>
    	<td style="text-align:left;"><span style="font-weight:bold;">TOTAL: </span></td>
    	<td colspan="4" style="text-align:right"><span style="font-weight:bold" class="red" id="totalPrice"><?php echo format_number($totalPrice) ?> $</span></td>
    </tr>
</table>
</div>

<script>
	$(document).ready(function()
	{
		$(".btnCartDel").live("click", function()
		{
			var this_tr = $(this).parent().parent();
			var product_id = $(this).attr("prod");
			var option_id = $(this).attr("opt");
			$.post("<?php echo url_for("@cart_delete")?>", {product_id: product_id, option_id: option_id}, function(data) {
				this_tr.remove();
				$("#totalPrice").html(data);
			});
			$.post("<?php echo url_for("@cart_quantity")?>", {}, function (data) {
				$("#link_to_cart").html(data);
			})
		});
	});
</script>